#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>

/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int cmp(const void* a, const void* b)
{
    return *(int*)a - *(int*)b;
}
int* smallestK(int* arr, int arrSize, int k, int* returnSize)
{
    int n = arrSize;
    qsort(arr, n, sizeof(arr[0]), cmp);
    *returnSize = k;
    int* ans = (int*)malloc(sizeof(int) * k);
    for (int i = 0; i < k; i++)
    {
        ans[i] = arr[i];
    }
    return ans;
}
